package org.luxor.schedule.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.luxor.commons.core.utils.BeanUtils;
import org.luxor.commons.jdbc.annotation.DS;
import org.luxor.commons.schedule.entity.ScheduleJobLogEntity;
import org.luxor.commons.schedule.service.IScheduleJobLogService;
import org.luxor.schedule.mapper.ScheduleJobLogMapper;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 定时任务日志
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.2.0 2016-11-28
 */
@Service("scheduleJobLogService")
@DS("${spring.quartz.dataSource:master}")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogMapper, ScheduleJobLogEntity> implements IScheduleJobLogService {

    @Override
    public IPage<ScheduleJobLogEntity> page(IPage<ScheduleJobLogEntity> page, Map search) {
        ScheduleJobLogEntity query = BeanUtils.toObject(ScheduleJobLogEntity.class, search);
        return super.page(page, Wrappers.query(query));
    }

    @Override
    public boolean saveLog(ScheduleJobLogEntity scheduleJobLog) {
        return super.save(scheduleJobLog);
    }

}
